﻿
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item active" aria-current="page">Plugins</li>
    </ol>
</nav>

<ul class="nav">
    <li class="nav-item">
        <a class="nav-link disabled" href="/Plugins/Index" tabindex="-1" aria-disabled="true">本地插件</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="/Plugins/Repository">远程可用插件</a>
    </li>
</ul>

<ul class="list-group list-group-flush">
    @foreach (var item in ViewBag.CurrentPlugins)
    {
        <li class="list-group-item">
            <div>
                <h4>
                    <span>
                        @item.Name
                    </span>
                    &nbsp;
                    <span>@item.Version</span>
                    <button type="button" class="btn btn-link" data-id="@item.Name" data-platform="@item.Platform">delete</button>
                </h4>
                <p>
                    @item.Description
                </p>
            </div>
        </li>
    }

</ul>
@section Scripts{ 

    <script>

        $('.list-group-item button').on('click', function () {
            deletePlugin($(this).attr('data-id'), $(this).attr('data-Platform'));
        })


        function deletePlugin(pluginname,platform) {
            $.post("/Plugins/DeletePlugin", { pluginname: pluginname, platform: platform}, function (res) {
                if (res.code == 1) {
                    location.reload();
                }
            });
        }
    </script>

}
